package com.wn.manpower.web;

import com.wn.common.PageBean;
import com.wn.common.ResponseEntity;
import com.wn.entity.Dimission;
import com.wn.entity.OfficeSupplies;
import com.wn.manpower.service.DimissionService;
import com.wn.manpower.service.OfficeSuppliesService;
import com.wn.manpower.vo.DimissionVo;
import com.wn.manpower.vo.OfficeSuppliesVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 办公用品
 * @author dzj
 * date: 2022/10/20
 */
@RestController
@RequestMapping("/manpower/officesupplies")
public class OfficeSuppliesController {

    @Autowired
    private OfficeSuppliesService officeSuppliesService;

    @RequestMapping("/add")
    public ResponseEntity add(@RequestBody OfficeSupplies officeSupplies) {
        officeSuppliesService.add(officeSupplies);
        return ResponseEntity.success;
    }

    @RequestMapping("/update")
    public ResponseEntity update(@RequestBody OfficeSupplies officeSupplies) {
        officeSuppliesService.update(officeSupplies);
        return ResponseEntity.success;
    }

    @RequestMapping("/getById/{id}")
    public ResponseEntity getById(@PathVariable int id) {
        OfficeSupplies officeSupplies = officeSuppliesService.getById(id);
        return new ResponseEntity(officeSupplies);
    }

    @RequestMapping("/getPageByCondition")
    public ResponseEntity getByCondition(@RequestBody OfficeSuppliesVo officeSuppliesVo) {
        PageBean<OfficeSupplies> pageBean = officeSuppliesService.getPageByCondition(officeSuppliesVo.getOfficeSupplies(), officeSuppliesVo.getCurrPage(), officeSuppliesVo.getPageSize());
        return new ResponseEntity(pageBean);
    }

    @RequestMapping("/del/{id}")
    public ResponseEntity del(@PathVariable int id) {
        officeSuppliesService.del(id);
        return ResponseEntity.success;
    }
}
